<template>
<div >
  <!--已完成-->
  <div class="paper-complete a-c" v-if="paperObj.paperType&&paperObj.paperType==3||paperObj.paperQuestion==null">
     <img src="https://youlingqinius.wonderlandnet.cn/diaocha.png" alt="" >
     <p>问卷调查已完成，感谢您的参与</p>
     <div class="paper-confirm complete-button text-center" @click="$router.go('-1')">确定</div>
  </div>
  <div v-else-if="paperObj.paperType&&paperObj.paperType==2">
    <div class="multi-content">
          <div class="title" v-if="paperObj.paperQuestion">{{paperObj.paperQuestion.index}}、{{paperObj.paperQuestion.content}}
            <span v-if="paperObj.paperQuestion.need==1">*</span> 
            【{{paperObj.paperQuestion.type==0?'单选':paperObj.paperQuestion.type==1?'多选':'文本'}}题】
          </div>
          <div  v-if="paperObj.paperQuestion&&paperObj.paperQuestion.type!=2" class="pb30">
            <div class="choice flex" v-for="(item,index) in paperObj.paperQuestion.paperOptions" :key="item.id" >
              <div class="flex" @click="$emit('checkItem',item)">
                <div v-if="paperObj.paperQuestion.type==0" >
                    <img src="~img/danxuan.png" v-if="!item.isSelected">
                    <img src="~img/danxuan-pre.png" v-else>
                </div>
                <div  v-else-if="paperObj.paperQuestion.type==1">
                    <img src="~img/duoxuan.png" v-if="!item.isSelected">
                    <img src="~img/duoxuan-pre.png"  v-else>
                </div>
                <span class="choice-num">{{letterList[index]}}、 </span>
                <span class="choice-content">{{item.content}}</span>
              </div>
              <div v-if="item.isTextShow&&item.isTextShow==1">
                <textarea @keyup="onkeyup(index)" ref="paper" class="paper-textarea" :class="{'text-empty-error':item.textEmptyError}"  v-model="item.textContent" ></textarea>
                <p class="choice-text-hint">{{item.textEmptyError?"这项填空必填哦":"请在这里留下您的想法吧~"}}</p> 
              </div>
            </div>
          </div>
         <textarea name="" id="" class="text-area" v-model="paperObj.inputtext" v-else></textarea>
        <img src="https://youlingqinius.wonderlandnet.cn/diaocha40.png" alt="" class="multi-back">
    </div>
    <div class="h-c">
     <div class="paper-confirm  text-center previous-ques" @click="$emit('goNext',{type:1,inputtext:paperObj.inputtext})" v-if="paperObj.paperQuestion&&paperObj.paperQuestion.index!=1">上一题</div>
     <div class="paper-confirm  text-center"  @click="$emit('goNext',{type:2,inputtext:paperObj.inputtext})">下一题</div>
    </div>
    <p style="height:30px"></p>
  </div>
</div>
</template>

<script>
export default {
  name: 'multichoice',
  components: {},
  props: {
    paperObj: {
      type: Object,
      defalut: {}
    }
  },

  data() {
    return{
      letterList:['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'],
    }
  },

  computed: {},

  watch: {},

  created() {
  },

  mounted() {},

  destroyed() {},

  methods: {
    onkeyup(index){
      this.$refs.paper[0].style.height = "1.05rem";
      this.$refs.paper[0].style.height = this.$refs.paper[0].scrollHeight+"px";
    }
  }

}
</script>

<style lang="less" scoped>
.multi-content{
  min-height: 7.2rem;
  border-radius: 10px;
  margin: 0.3rem;
  position: relative;
  background: #ffffff;
  padding:0 0.5rem;
  box-shadow: 0px 0px 0.14rem 0.06rem rgba(0, 0, 0, 0.16);
  .title{
    font-weight: bold;
    padding-top: 0.5rem;
    font-size: 0.36rem;
    color: #3a3a3a;
    span{
      color: #fb685b;
    }
  }
  .choice{
    padding-top: 0.38rem;
    line-height: 1;
    flex-direction: column;
    img{
      width: 0.28rem;
      height: 0.28rem;
    }
    .choice-content{
      font-size: 0.3rem;
      color: #3a3a3a;
    }
    .choice-num{
      margin: 0 0.2rem;
    }
    .paper-textarea{
      margin-top: 0.15rem;
      min-height:0.66rem;
      width: 6rem;
      resize:none ;
      border-radius: 5px;
      background: #f7f7f7;
      line-height: 1.8;
      border: 1px solid #d1cfcf;
    }
    .choice-text-hint{
      padding-top: 0.15rem;
      color: #fb685b;
      font-size: 0.26rem;
    }
    .text-empty-error{
     border: 1px solid #fb685b;
    }
  }
  .multi-back{
    position: absolute;
    bottom: 0.38rem;
    right: 0.4rem;
    width: 2.8rem;
    height: 2.8rem;
  }
  .text-area{
    width: 5.8rem;
    height: 2.2rem;
    margin-top: 0.55rem;
    font-size: 0.28rem;
    line-height: 1.8;
    color: #3a3a3a;
    resize:none ;
    background: white;
    border: 1px solid #e6e6e6
  }
}
.paper-complete{
  height: 90vh;
  flex-direction: column;
  img{
    width: 2.8rem;
    height: 2.8rem;
  }
  p{
    margin: 0.35rem 0 0.68rem 0;
    font-size: 0.34rem;
    color: #3a3a3a;
  }
  .complete-button{
    font-size: 0.32rem
  }
}
.previous-ques{
  background: #494949;
  margin-right: 0.2rem
}
.mb30{
  margin-bottom: 0.3rem
}
.pb30{
  padding-bottom: 0.3rem
}
</style>

